using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace EcoEstadisticas
{
    class ConeccionBD
    {
        private static ConeccionBD instance = new ConeccionBD();
        private SqlConnection coneccion = new SqlConnection("Data Source=localhost\\SQLSERVER2005;Initial Catalog=Economia;user=sa;password=gestiondedatos");    
        private ConeccionBD()
        {
            try
            {
                this.coneccion.Open();
            }
            catch (SqlException sqlE)
            {
                this.cerraConeccion();
            }
        }

        public SqlConnection getConneccion(){
            return this.coneccion;
        }

        public void cerraConeccion()
        {
            this.coneccion.Close();
        }

        public static ConeccionBD getInstance()
        {
            return instance;
        }
    }
}
